/* @flow */

import React, { Component } from 'react';
import {
  View,
  Text,
  StyleSheet,
} from 'react-native';

import { combineReducers } from 'redux';

import { NavigationActions } from 'react-navigation';


const initialAuthState = { isShowTab: true };
const initialState = { testShow: true};

function nav (state = initialAuthState, action) {

  console.log("action type: %s",action.type);

  switch (action.type) {
    case 'push':{

    }
      break;
    case 'pop':{

    }
      break;
    case 'act':{

    }
      break;
    case 'tab_nav_changed':{
      return Object.assign({}, state, {
        index: action.index
      })
    }
      break;

    default:

  }
  return state;
}

const home = (state = initialState, action) => {
  switch (action.type) {
    case 'homeshowTabBar':{

      console.log("homeshowTabBar：%s",action.testShow);

      return Object.assign({}, state, {
        testShow: action.testShow
      })
    }
    default:
    return state;

  }
}

const find = (state = initialState, action) => {
  switch (action.type) {
    case 'findshowTabBar':{
      return Object.assign({}, state, {
        testShow: action.testShow
      })
    }
    default:
    return state;

  }
}



//test kael reducerCreator
// export const testCreator = myCreatorForReducer([], {
//   [ActionTypes.ADD_TODO](state, action) {
//     let text = action.text.trim();
//     return [...state, text];
//   }
// })
//
// const myCreatorForReducer = (initialState,handles) => {
//
//   return (state=initialState,action) => {
//     return handles[action.type](state,action);
//   }else {
//     return state;
//   }
//
// }


const AppReducer = combineReducers({
  nav,
  home,
  find,
});

export default AppReducer;
